// 测试数据生成方法
// 用于接口伪装
const random = (min, max) => min + Math.floor(Math.random() * (max - min + 1))
let renderFunction = (label) => {
    var total = random(0, 100);
    var online = random(0, total);
    var working = random(0, online);
    return {
        label: label,
        total: total,
        online: online,
        working: working
    }
}
let LabelArray = ["一类", "二类", "三类", "四类", "监测", "船载", "便携", "传感器"];

const install = () => {
    // 数据由同步获取改为异步获取
    return new Promise((resolve, reject) => {
        let res = [];
        LabelArray.forEach(item => {
            res.push(renderFunction(item))
        });
        // 给数组一个随机函数，用来打乱数组顺序（给自己增加难度）
        res.sort((a, b) => Math.random() > 0.5 ? 1 : -1)
        resolve(res);
    });
}

export default install;